package com.nbsaas.boot.wms.rest.convert;

import com.nbsaas.boot.wms.data.entity.Warehouse;
import com.nbsaas.boot.wms.api.domain.request.WarehouseRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.wms.data.entity.WarehouseCatalog;

/**
 * 仓库请求对象转换成实体对象
 */

public class WarehouseEntityConvert implements Converter<Warehouse, WarehouseRequest> {

    @Override
    public Warehouse convert(WarehouseRequest source) {
        Warehouse result = new Warehouse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getCatalog() != null) {
            WarehouseCatalog catalog = new WarehouseCatalog();
            catalog.setId(source.getCatalog());
            result.setCatalog(catalog);
        }
        return result;
    }
}

